GtkStackSwitcher: Pick up the visible child from the stack
authorMatthias Clasen <mclasen@redhat.com>
Tue, 7 Oct 2014 03:06:09 +0000 (23:06 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 7 Oct 2014 03:06:09 +0000 (23:06 -0400)
We forgot to synchronize the visible child when setting a
stack on the switcher. Oops.

gtk/gtkstackswitcher.c

index 9a114bcb4321947653ea0d5680b6ad1f70d49536..42e683f5e29d733fada971075d4067734d87592e 100644 (file)
@@ -292,9 +292,17 @@ static void
 populate_switcher (GtkStackSwitcher *self)
 {
   GtkStackSwitcherPrivate *priv;
+  GtkWidget *widget, *button;
 
   priv = gtk_stack_switcher_get_instance_private (self);
   gtk_container_foreach (GTK_CONTAINER (priv->stack), (GtkCallback)add_child, self);
+
+  widget = gtk_stack_get_visible_child (priv->stack);
+  if (widget)
+    {
+      button = g_hash_table_lookup (priv->buttons, widget);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+    }
 }
 
 static void